home *** CD-ROM | disk | FTP | other *** search
- Path: noc.netcom.net!news
- From: Tarang Deshpande <tarang@willows.com>
- Newsgroups: comp.lang.c,comp.lang.c++
- Subject: Re: H E L P
- Date: Tue, 02 Apr 1996 15:07:02 -0800
- Organization: NETCOM Network Operations
- Message-ID: <3161B316.3345@willows.com>
- References: <N.040296.013047.18@DynamicPPP-185.HIP.CAM.ORG>
- NNTP-Posting-Host: daffy.willows.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0GoldB2 (Win95; I)
-
- ramrod@cam.org wrote:
- >
- > Could anyone please tell me how to write the following program.
- > Using nested looping, the output is supposed to look like this.
- >
- > Please enter your age in years (0 to end the program): 10
- > Happy Birthday To You
- > You are 10 Years Old
- >
- > \x01\x01\x01\x01\x01\x01\x0\x01\x01\x01(ten happy faces)
- >
- > The part that I am having a hard time with is the part that
- > whatever number I enter for the age, I'm supposed to get the same number
- > of happy faces, automatically. For example If I say I am 45 years old,
- > then the program should show 45 happy faces.
-
- void main ()
- {
-
- int Years;
- int HappyFace;
-
- do
- {
- printf ( "Please enter your age in years (0 to end the program): " );
- scanf ( "%d" &Years );
- if ( Years )
- {
- printf ( "Happy Birthday To You\n" );
- printf ( "You are %d Years Old\n", Years );
- for ( HappyFace = 0; HappyFace < Years; HappyFace++ )
- printf ( "%c", ( char ) 1 );
- }
- } while ( Years );
-
- }
-